#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
struct student
{
	int score;
	char name[20];
};
int main()
{
	struct student stu[100];
	int i, j;
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d %s", &stu[i].score, stu[i].name);
	}
	for (i = 0; i < n - 1; i++)
	{
		for (j = 0; j < n - 1 - i; j++)
		{
			if (stu[j].score < stu[j + 1].score)
			{
				struct student t = stu[j];
				stu[j] = stu[j + 1];
				stu[j + 1] = t;
			}
		}
	}
	printf("%s", stu[0].name);
	return 0;
}